//
//  RightViewController.m
//  MansApp
//
//  Created by lanou3g on 15/7/22.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "RightViewController.h"
#import "NoteTableViewController.h"
#import "TapeTableViewController.h"
@interface RightViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *myArray;
@end

@implementation RightViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"更多设置";
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kP6width(150), kHeight) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    self.myArray = @[@"我的日记",@"我的录音",@"清除缓存"];
   
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    }
    
    cell.textLabel.text = self.myArray[indexPath.row];
    cell.textLabel.font = [UIFont fontWithName:@"Courier-BoldOblique" size:17];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:{
              NSMutableArray *arr = [[ACHdb sharedInstance] showTheTableAll];
    
    if ([arr.firstObject count] != 0) {
        
        NoteTableViewController *note = [[NoteTableViewController alloc]init];
        note.myArray = arr;
        UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:note];
        [self presentViewController:navi animated:YES completion:nil];
    }  
        }
            break;
        case 1:{
            NSMutableArray *arr = [[ACHdb sharedInstance] showTheTableAll];
            
            if ([arr.firstObject count] != 0) {
                
                TapeTableViewController *tape = [[TapeTableViewController alloc]init];
                tape.myArray = arr;
                UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:tape];
                [self presentViewController:navi animated:YES completion:nil];
            
            }
        }
            break;
        default:
            [[SDImageCache sharedImageCache] clearMemory];
            [MBProgressHUD showError:@"清除缓存成功"];
            break;
    }
   

    //    NSLog(@"%@",arr.firstObject);
    
  
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
